
#[derive(Debug)]
struct User {
    name: String,
    score: u64
}


pub fn test_closures_use(){
    println!("对结构体: User 按照分数进行排序");
    let u1 = User {
        name : "u1".to_string(),
        score: 100,
    };

    let u2 = User {
        name: "u2".to_string(),
        score: 20,
    };

    let u3 = User {
        name: "u3".to_string(),
        score: 30
    };

    let mut users = vec![u1,u2,u3];

    users.sort_by_key(|u| u.score);

    println!("{:?}", users);
}